
#include "apue.h"
#include "error.c"
#include <dirent.h>

int main(int argc, char**argv)
{
   //std::cout << "Hello, world!\n";
    // err_sys("some error found %d\n", getpid());
    
    DIR     *dp;
    struct dirent   *dirp;
    if(argc != 2)
        err_quit("usage: 1s directory_name");
    
    if((dp = opendir(argv[1])) == NULL)
        err_sys("can't open %s", argv[1]);
    
    while((dirp = readdir(dp)) != NULL)
        printf("%s\n", dirp->d_name);

    closedir(dp);

    
   return 0;
}
